﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PurchaseOutAdd.aspx.cs" Inherits="Automobile.service.UI.PurchaseOutAdd" %>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="/favicon.ico" >
<LINK rel="Shortcut Icon" href="/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="http://lib.h-ui.net/html5.js"></script>
<script type="text/javascript" src="http://lib.h-ui.net/respond.min.js"></script>
<script type="text/javascript" src="http://lib.h-ui.net/PIE_IE678.js"></script>
<![endif]-->

<link href="static/h-ui/css/H-ui.min.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.admin.css" />
<link href="lib/Hui-iconfont/1.0.7/iconfont.css" rel="stylesheet" />
<link href="lib/icheck/icheck.css" rel="stylesheet" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<!--/meta 作为公共模版分离出去-->

<title>添加管理员 - 管理员管理 - H-ui.admin v2.4</title>
<meta name="keywords" content="H-ui.admin v2.3,H-ui网站后台模版,后台模版下载,后台管理系统模版,HTML后台模版下载">
<meta name="description" content="H-ui.admin v2.3，是一款由国人开发的轻量级扁平化网站后台模板，完全免费开源的网站后台管理系统模版，适合中小型CMS后台系统。">
</head> 
<body>
<article class="page-container">
	<form class="form form-horizontal" runat="server">
            <div  class="cl pd-5 bg-1 bk-gray mt-20""> 
            <label><span class="c-red">*</span>供应商名称：</label>
            <asp:DropDownList ID="DropDownList1" runat="server" Width="147px" ></asp:DropDownList>
            <label><span class="c-red">&nbsp; *</span>出货仓库：</label>
            <asp:DropDownList ID="DropDownList2" runat="server" Width="147px"></asp:DropDownList>
             <label><span class="c-red" >&nbsp; 
                <br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *</span>备注&nbsp;&nbsp;&nbsp;</label><input type="text"  id="Purchase_Remark" style="width:147px;" ><label><span class="c-red">&nbsp;&nbsp;&nbsp;&nbsp; *</span>  经办人：</label>
            <asp:DropDownList ID="DropDownList3" runat="server" Width="147px"></asp:DropDownList>
        </div>
        <div> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="text"  id="Product_Modelspe" style="width:200px;"><input id="Button1" type="button" value="搜索"  onclick="fun()" style="border-radius:15px;width:100px;background-color:#00ff21"/><input id="Button3" type="button" value="清空"  onclick="fun2()" style="border-radius:15px;width:100px;background-color:#00ff21"/></div>
        	<table class="table table-border table-bordered table-bg table-hover table-sort" id="psser">
			<thead>
				<tr class="text-c">
                 <th>
                     <input id="Checkbox1" type="checkbox"  onclick="check1()"/></th>
				<th>商品名称</th>
				<th>规格型号</th>
				<th>进价</th>
				<th>商品类别</th>
                <th>生产厂商</th>
                <th>数量</th>
                <th>总金额</th>
				</tr>
			</thead>
			<tbody>
				
			</tbody>
		</table>
        </form>
    <div>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input id="Button2" type="button" value="确认"  onclick="    check()" style="width:200px;height:25px;border-radius:15px;background-color:#2bd4ab"/></div>
</article>
<!--_footer 作为公共模版分离出去--> 
<script type="text/javascript" src="jquery.validation/1.14.0/messages_zh.min.js"></script> 
<script type="text/javascript" src="static/h-ui/js/H-ui.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> 
<!--/_footer /作为公共模版分离出去--> 
<script src="js/jquery-1.8.2.min.js"></script>
<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript">
//$(function(){
//	$('.skin-minimal input').iCheck({
//		checkboxClass: 'icheckbox-blue',
//		radioClass: 'iradio-blue',
//		increaseArea: '20%'
//	});
	
//	$("#form-admin-add").validate({
//		rules:{
//			adminName:{
//				required:true,
//				minlength:4,
//				maxlength:16
//			},
//			password:{
//				required:true,
//			},
//			password2:{
//				required:true,
//				equalTo: "#password"
//			},
//			sex:{
//				required:true,
//			},
//			phone:{
//				required:true,
//				isPhone:true,
//			},
//			email:{
//				required:true,
//				email:true,
//			},
//			adminRole:{
//				required:true,
//			},
//		},
//		onkeyup:false,
//		focusCleanup:true,
//		success:"valid",
//		submitHandler:function(form){
//			$(form).ajaxSubmit();
//			var index = parent.layer.getFrameIndex(window.name);
//			parent.$('.btn-refresh').click();
//			parent.layer.close(index);
//		}
//	});
//});
</script> 
     <script src="js/jquery-1.8.2.min.js" type="text/javascript"></script>
<!--/请在上方写此页面业务相关的脚本-->
    <script type="text/javascript">
        function fun() {
            var ss = $("#Product_Modelspe").val();
            alert(ss);
                $.ajax({
                    type: "post",
                    url: "Handler/PurchaseOut_Show.ashx",
                    data: {
                        Product_Modelspe: ss,
                    },
                    success: function (data1) {
                        var data = eval(data1);
                        for (var i in data) {
                            var pp = "<tr class='text-c' id='P" + data[i].Product_Id + "'><td><input id='Checkbox" + data[i].Product_Id + "' type='checkbox' value='" + data[i].Product_Id + "' name='ck'/></td><td>" + data[i].Product_Name + "</td><td>" + data[i].Product_Modelspe + "</td><td  id='price" + data[i].Product_Id + "'>" + data[i].Product_Price + "</td><td>" + data[i].Product_Type_Name + "</td><td>" + data[i].Product_frim + "</td><td><input id='num" + data[i].Product_Id + "' type='text'  style='width:200px;' onchange='fun1(" + data[i].Product_Id + ")' name='num' /></td><td><span id='SumMoney" + data[i].Product_Id + "' name='SumMoney'>0</span>元</td></tr>";
                            if ($("#P" + data[i].Product_Id + "").length>0)
                            {
                                alert("已存在");
                                return;
                            }
                            else
                            {
                                $(".table tbody").append(pp);
                            }
                   
                        }
                    }
                })
            }

        function fun1(id)
        {
            var num = $("#num" + id + "").val();
            var price = $("#price" + id + "").html();
            var sum = num * price;  
            $("#SumMoney" + id + "").html(sum);
           
        }
        function check()
        {
            //$(":checkbox").each(function () {
            //    if ($(this).attr("checked") == "checked") {
            //        var por=$(this).val();
            //    }
            //});
            //var num = "";
            //var SumMoney = "";
            //var selectvalue = "";
            //var emplist = $("[name='ck']:checked");
            //$(emplist).each(function (index, item) {
            //    ss = $(item).val();
            //    num += $("#num" + ss + "").val() + ",";
            //    SumMoney += $("#SumMoney" + ss + "").html() + ",";
            //    if(selectvalue.length>0)
            //    {
            //        selectvalue += ",";
            //    }
            //    selectvalue += $(item).val();
            //})
            //num = num.substr(0, num.length - 1);
            //SumMoney = SumMoney.substr(0, SumMoney.length - 1);
            ////alert(selectvalue);
            //alert(num);
            var Supplier_Id = $("#DropDownList1 option:selected").val();
            var WareHose_Id = $("#DropDownList2 option:selected").val();
            var Employee_Id = $("#DropDownList3 option:selected").val();
            var Product_Id = new Array();
            var i = -1;
            $("[name='ck']").each(function () {
                i++;
                Product_Id[i] = $(this).val();

            })
            var PurchaseMate_Num = new Array();
            var p = -1;
            $("[name='num']").each(function () {
                p++;
                PurchaseMate_Num[p] = $(this).val();
            })
      
            var PurchaseMate_Price = new Array();
            var r = -1;
            $("[name='SumMoney']").each(function () {
                r++;
                PurchaseMate_Price[r] = $(this).html();

            })
            //字符拼接XML;
            var xml = "<mm>"
            for (var i = 0; i < $("[name='num']").length; i++) {
                xml += "<xx Product_Id='" + Product_Id[i] + "' PurchaseMate_Num='" + PurchaseMate_Num[i] + "' PurchaseMate_Price='" + PurchaseMate_Price[i] + "' />";

            }
            xml+="</mm>"
            var encodexml = encodeURIComponent(xml);
            var sumM = 0;
            $("[name='SumMoney']").each(function () {

                sumM += parseInt($(this).html());
            })
            $.ajax({
                type: "post",
                url: "Handler/PurchaseOut_Add.ashx",
                data: {
                    sumM: sumM,
                    Supplier_Id: Supplier_Id,
                    WareHose_Id: WareHose_Id,
                    Employee_Id: Employee_Id,
                    Purchase_Remark:$("#Purchase_Remark").val(),
                    xml: encodexml
                },
                success: function (data) {
                    if(data>0)
                    {
                        alert("OK");
                    }
                    else
                    {
                        alert("No");
                    }

                },
                error: function () {

                    alert("Game over")
                }
            })

        }
        function fun2()
        {
            $(".table tbody").empty("");
        }
    </script>
</body>
</html>

